package com.fau.fm.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 产品销售量统计表
 * @author liy
 * @datetime 2014年9月12日,上午10:52:45
 */
@Entity
@Table(name = "medical_product_storage")
public class MedicalProductStorage implements Serializable, JSONAware{

	private static final long serialVersionUID = -6108594727060510669L;

	private String id;
	private String serialNum;		// 编号
	private String status;			// 所处状态
	private BigDecimal payment;		// 货款
	private BigDecimal freight;		// 运费
	private String hospitalId;		// 医院id
	private String orderId;			// 订单id
	private String groupId;			// 话务组id
	private String userId;			// 话务员id
	private String productId;		// 产品id
	private String productName;		// 产品名称
	private Integer productNum;		// 产品数量
	private String logisticId;		// 物流公司id
	private BigDecimal productPrice;	// 产品单价
	
	private Date createTime;	// 下单时间
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "serial_num", length = 50)
	public String getSerialNum() {
		return serialNum;
	}

	public void setSerialNum(String serialNum) {
		this.serialNum = serialNum;
	}
	
	@Column(name = "status", length = 20)
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Column(name = "payment", length = 20)
	public BigDecimal getPayment() {
		return payment;
	}

	public void setPayment(BigDecimal payment) {
		this.payment = payment;
	}

	@Column(name = "freight", length = 20)
	public BigDecimal getFreight() {
		return freight;
	}

	public void setFreight(BigDecimal freight) {
		this.freight = freight;
	}

	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}
	
	@Column(name = "order_id", length = 32)
	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	@Column(name = "group_id", length = 32)
	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	@Column(name = "user_id", length = 32)
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	@Column(name = "product_id", length = 32)
	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	@Column(name = "product_name", length = 50)
	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	@Column(name = "product_num", length = 11)
	public Integer getProductNum() {
		return productNum;
	}

	public void setProductNum(Integer productNum) {
		this.productNum = productNum;
	}

	@Column(name = "logistic_id", length = 32)
	public String getLogisticId() {
		return logisticId;
	}

	public void setLogisticId(String logisticId) {
		this.logisticId = logisticId;
	}

	@Column(name = "product_price", length = 20)
	public BigDecimal getProductPrice() {
		return productPrice;
	}

	public void setProductPrice(BigDecimal productPrice) {
		this.productPrice = productPrice;
	}

	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	
	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		
		obj.put("id", id);
		obj.put("serialNum", serialNum);
		obj.put("status", status);
		obj.put("payment", payment);
		obj.put("hospitalId", hospitalId);
		obj.put("orderId", orderId);
		obj.put("groupId", groupId);
		obj.put("userId", userId);
		obj.put("productId", productId);
		obj.put("productName", productName);
		obj.put("productNum", productNum);
		obj.put("logisticId", logisticId);
		obj.put("productPrice", productPrice);
		obj.put("freight", freight);
		obj.put("createTime", DateFormatUtils.format(createTime, "yyyy-MM-dd HH:mm:ss"));
		return obj.toString();
	}
}
